﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeTier.DAL;

namespace CodeTier.BUL
{
    public class PhieuDatHangBUS
    {
        public int MaPDH { get; set; }
        public int MaKH { get; set; }
        public DateTime NgayDat { get; set; }
        public int TongTriGia { get; set; }
        public List<ChiTietPhieuDatHangBUS> lst_ct{get;set;}

        public PhieuDatHangBUS()
        {
        }


        public static List<PhieuDatHangBUS> getAll()
        {
            var results = from p in CommonDAO.XDMH.PhieuDatHangs
                          select p;
            List<PhieuDatHangBUS> lst_pdh = new List<PhieuDatHangBUS>();
            foreach (var result in results)
            {
                PhieuDatHangBUS pdh = new PhieuDatHangBUS();
                pdh.MaPDH = result.MaPDH;
                pdh.MaKH = result.MaKH;
                pdh.NgayDat = result.NgayDat;
                pdh.TongTriGia = Convert.ToInt32(result.TongTriGia);
                pdh.lst_ct = ChiTietPhieuDatHangBUS.getAll(pdh.MaPDH);
                lst_pdh.Add(pdh);
            }
            return lst_pdh;
        }
    }
}
